The following program replicates example 2.4.1 (pp.23-28) from Johansen (1995) Likelihood-based Inference in Cointegrated Vector Auto-regressive Models, Oxford University Press.
'replicate example 2.4.1 (pp.23-28)'Johansen (1995) Likelihood-based Inference in Cointegrated'Vector Auto-regressive Models, Oxford University Press'' checked 3/7/2007 'change path to program path%path = @runpathcd %path 'create workfilewfcreate denmark q 1974:1 1987:3 'fetch data from database'data downloaded from johansen's website at'http://www.math.ku.dk/~sjo/data/data.htmlfetch(d=var_dat) lrm lry ibo ide 'create centered seasonal dummiesfor !i=1 to 3 series d{!i} = @seas(!i) - 0.25next 'estimate unrestricted VARvar var1.ls 1 2 lrm lry ibo ide @ c d1 d2 d3 'replicate residual correlation matrix'Table 2.4 (p.24)freeze(tab24) var1.residcorshow tab24 'replicate univariate residual diagnostics'Table 2.5 (p.25)'note that Johansen reports *excess* kurtosis relative to 3.0'also JB statistic does not match; why?var1.makeresid(name=gres) res1 res2 res3 res4freeze(tab25) gres.statsshow tab25 'replicate roots in Table 2.6 (p.25)freeze(tab26) var1.arrootsshow tab26 'show roots in unit circlefreeze(gra26) var1.arroots(graph)show gra26 'replicate auto-correlation functions'Fig 2.3 (p.28)'note that eviews graph is transpose of Fig 2.3freeze(fig23) var1.correl(15,graph)fig23.options size(4,2)fig23.align(4,1,1)show fig23
The following program replicates example 7.3.1 (pp.112-116) from Johansen (1995) Likelihood-based Inference in Cointegrated Vector Auto-regressive Models, Oxford University Press. Note that while Johansen's lag specification is in terms of levels of the original series, EViews' VEC specification is in terms of lags of first difference terms.
The program also illustrates how to carry out weak exogeneity tests (by testing zero restrictions on the adjustment coefficients) conditional on restrictions imposed on the cointegrating vector. Currently, EViews only carries out joint restriction tests so you have to manually compute the LR test statistic for conditional tests.
'Johansen cointegration restrictions'replicate example 7.3.1 (pp.112-116)'Johansen (1995) Likelihood-based Inference in Cointegrated'Vector Auto-regressive Models, Oxford University Press'' last checked 3/25/2004 'change path to program path%path = @runpathcd %path 'create workfilewfcreate denmark q 1974:1 1987:3 'fetch data from database'data downloaded from johansen's website at'http://www.math.ku.dk/~sjo/data/data.htmlfetch(d=var_dat) lrm lry ibo ide 'create centered seasonal dummiesfor !i=1 to 3 series d{!i} = @seas(!i) - 0.25next 'estimate VEC with intercept restricted in cointegrating relationvar vec1.ec(b,1) 1 1 lrm lry ibo ide @ d1 d2 d3 'show cointegration test results'replicates Tables 7.1 (p.113), 7.2 (p.113), 7.3 (p.114)'note that EViews uses slightly different critical values'note also that EViews reports *transpose* of Table 7.2freeze(tab71) vec1.coint(b,1)show tab71 'show unrestricted cointegrating relation'replicate Fig 7.1 (left graph)vec1.makecoint gcointfreeze(fig71) gcoint.linefig71.draw(dashline,left) 0.0show fig71 '-------------------------------------------------------------------------------'test b1+b2=0'-------------------------------------------------------------------------------vec1.cleartext(coint)vec1.append(coint) b(1,1) + b(1,2) = 0 freeze(test1) vec1.coint(b,1,restrict,c=1e-5,m=100)show test1 '-------------------------------------------------------------------------------'test b1+b2=0 and b3+b4=0'note that this test is different from the test reported in Johansen (p.115)'which is a test of b3+b4=0 conditional on b1+b2=0'------------------------------------------------------------------------------- vec1.append(coint) b(1,3) + b(1,4) = 0vec1.append(coint) b(1,1) = 1.0 'save restricted logl in mat2 for later usefreeze(test2) vec1.coint(b,1,restrict,c=1e-5,m=100,save=mat2)show test2 'get restricted cointegrating vectorvec1.ec(b,1,restrict,c=1e-5,m=100) 1 1 lrm lry ibo ide @ d1 d2 d3matrix cv1 = vec1.@cointvecshow cv1 '-------------------------------------------------------------------------------'test weak exogeneity a3=a4=0 conditional on b1+b2=0 and b3+b4=0'------------------------------------------------------------------------------- vec1.append(coint) a(3,1) = 0vec1.append(coint) a(4,1) = 0 'joint test on b and a'save restricted logl of joint test in mat3freeze(test3) vec1.coint(b,1,restrict,c=1e-5,m=100,save=mat3)show test3 'compute manually LR statistic for testing a3=a4=0'conditional on b1+b2=b3+b4=0'replicates first paragraph of p.116table outout(1,1) = "Weak exogeneity test (a3=a4=0) conditional on b1+b2=b3+b4=0"out(2,1) = "LR statistic = "!lr = 2.0*(mat2(1,4) - mat3(1,4))out(2,2) = !lrout(2,3) = "p-value = "out(2,4) = 1.0 - @cchisq(!lr,2) show out